package com.kohan.battleship;

import java.util.Scanner;


public class Main 
{
    private static boolean startTurn() {
        int turn = (int) (10.0 * Math.random());
        return turn < 5;
    }
    
    public static void main( String[] args )
    {
        System.out.println( "BattleShip" );
        Scanner in = new Scanner(System.in);
        System.out.println("Set your name:");
        
        User user = new User(in.nextLine());
        Pc pc = new Pc("PC", "red");
        //Board board = new Board();
        //board.showBoard();
        
        boolean hit;
        boolean turn = startTurn();
        
        while(!pc.isWin() || !user.isWin()) {
            if(!turn) {
                //pc's board
                pc.getBoard().showBoard();
                //user
                hit = user.hitShip(pc.getBoard());
                while(hit) {
                    pc.getBoard().showBoard();
                    hit = user.hitShip(pc.getBoard());
                }
            }
            
            else {
                user.getBoard().showBoard();
                //pc
                hit = pc.hitShip(user.getBoard());
                while(hit) {
                    user.getBoard().showBoard();
                    hit = pc.hitShip(user.getBoard());
                }
            }
        }
    }
}
